package com.yyh.synctool.server.controller;

import com.yyh.pojo.SyncParam;
import com.yyh.result.JsonResult;
import com.yyh.synctool.server.service.ProviderService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 接收同步请求的控制器
 *
 * @author xuan
 * @date 2021/12/3
 */
@RestController
@RequestMapping("/sync")
public class ProviderController
{
    private ProviderService providerService;

    @Autowired
    public ProviderController(ProviderService providerService) {
        this.providerService = providerService;
    }

    /** 接收库存同步任务 */
    @PostMapping("/stock")
    public JsonResult stock(@RequestBody SyncParam<List<Map>> syncParam) {
        return providerService.syncStock(syncParam);
    }

    @PostMapping("/price")
    public JsonResult price(@RequestBody SyncParam<List<Map>> syncParam) {
        return providerService.syncPrice(syncParam);
    }
}
